#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Stu
{
  int no;
  double a, b, c;
  char name[25];
  struct Stu *next;
}stu;
void creat(stu *p, int n);
void delandprt(stu *p, int num);

int main()
{
  stu *h;
  int n,num;
  h = (stu *)malloc(sizeof(stu));//头指针
  //h = new stu;//头指针
  h->next=NULL;
  while(~scanf("%d",&n))
  {
      creat(h, n);
      scanf("%d", &num);
      delandprt(h, num);
  }
  return 0;
}

void  creat(stu *p,int n)
{ 
  stu *q,*r=p;//q创结点，r串结点   尾插法
  int i;
  for(i=0;i<n;i++)
  {     
      q=(stu *)malloc(sizeof(stu));
      //q = new stu;
      scanf("%d  %s  %lf  %lf  %lf", &q->no, q->name, &q->a, &q->b, &q->c);
      r->next = q;
      r = q;
  }
  r->next=NULL;
}
void  delandprt(stu *p,int num)
{
    int flag=0;
    stu *q = p, *r; // q前驱，r待删除结点
    r = p->next;
    while (q->next != NULL)
    {
        if (r->no == num)
        {
            q->next = r->next;
            free(r);
            flag = 1;
            // r = q->next;
            break; //学号唯一，不会删除多个结点
        }
        else
        {
            r = r->next;
            q = q->next;
        }
  }
  if(flag==0)
      printf("Error\n");
  else
  {
      q = p->next;
      while(q!=NULL)
      {
          printf("%d  %s  %.2lf  %.2lf  %.2lf  ", q->no, q->name, q->a, q->b, q->c);
          printf("%.2lf  %.2lf\n",(q->a+q->b+q->c)/3.0,q->a+q->b+q->c);
          q = q->next;
      }
  }
}
